%read Slc6a5 pseudotime logistic regression data and make plot.
path1=['C:\Users\Tom�s\Desktop\Candelabrum Cell paper\Candelabrum Cells\Figures\Figure 1\'];


fileName='slc6a5_ordered_pseudotime_data.csv';

opts = detectImportOptions([path1 fileName]);
preview([path1 fileName],opts)


% opts = setvaropts(opts,'TreatAsMissing','nan');
% opts = setvaropts(opts,'TreatAsMissing','NaN');
opts.PreserveVariableNames=1
opts.MissingRule = 'fill';
% opts.TreatAsMissing='nan';
% opts.VariableNamesRange=1;

% opts = setvaropts(opts,{'spikelets'},'FillValue','nan');
% opts = setvaropts(opts,'FillValue','NaN');


M = readcell([path1 fileName],'NumHeaderLines',1);

for i=1:size(M,1)
    
%organize variables from cell array
if i==1
else
    pseudotime(i-1)=M{i,2};
    Slc6a5Value(i-1)=M{i,3};
    fit_values(i-1)=M{i,5};
    
    if strcmp(M{i,4},'Candelabrum')
        CCLogical(i-1)=1;
    else
        CCLogical(i-1)=0;
    end
end
end

CCColor=[27 192 218]./255;
GlobularColor=[74 184 89]./255; 




CCLogical=logical(CCLogical);
 fig2=figure(2);
fig2.Renderer='Painters';   

scatter(pseudotime(CCLogical),Slc6a5Value(CCLogical),'markerfacecolor',CCColor,'markerfaceAlpha',1,'markeredgecolor','none')
hold on
scatter(pseudotime(~CCLogical),Slc6a5Value(~CCLogical),'markerfacecolor',GlobularColor,'markerfaceAlpha',1,'markeredgecolor','none')
plot(pseudotime',fit_values','linewidth',1,'color','r');
box off


ylim([0 6]);
set(gca, 'XTick', [0:0.25:1 ]);
xticklabels({0,'',0.5,'',1})
set(gca, 'YTick', [0:1.5:6]);
yticklabels({0,'',3,'',6})
set(gca,'TickDir','out')
 set(gca, 'FontName', 'Arial')
box off
xlabel('Pseudotime')
ylabel('Normalized expression')



